; The name of the installer
Name "JavaSMFBackup"

; The default installation directory - controlled by ant or standalone.
InstallDir $PROGRAMFILES\JavaSMFBackup

!ifdef INSTALLERS_DIR
  ; if INSTALLERS_DIR is passed via ANT -> output file
  OutFile ${INSTALLERS_DIR}/JavaSMFBackup_setup.exe
!else
  ; compiled directly
  OutFile JavaSMFBackup_setup.exe
!endif

;--------------------------------

; Pages

LicenseData LICENSE.txt

Page license
Page directory
Page instfiles

;--------------------------------

; The stuff to install
Section "" ;No components page, name is not important

  ; Set output path to the installation directory.
  SetOutPath $INSTDIR
  
  ; Put file there
  File /r /x .svn lib
  File JavaSMFBackup.exe
  File SMFBackup.ico
  

 ; Write the uninstall keys for Windows
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JavaSMFBackup" "DisplayName" "Java SMF Backup - Backup Application for SMF Forums."
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JavaSMFBackup" "Publisher" "Iulian Virtejanu - http://hex.ro"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JavaSMFBackup" "UninstallString" '"$INSTDIR\uninstall.exe"'
  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JavaSMFBackup" "NoModify" 1
  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JavaSMFBackup" "NoRepair" 1
  WriteUninstaller "uninstall.exe"
   
SectionEnd ; end the section

Section "Start Menu Shortcuts"
  CreateDirectory "$SMPROGRAMS\Java SMF Backup"
  CreateShortCut "$SMPROGRAMS\Java SMF Backup\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
  CreateShortCut "$SMPROGRAMS\Java SMF Backup\Java SMF Backup.lnk" "$INSTDIR\JavaSMFBackup.exe" "" "$INSTDIR\SMFBackup.ico" 0
  
  CreateShortCut "$DESKTOP\Java SMF Backup.lnk" "$INSTDIR\JavaSMFBackup.exe" "" "$INSTDIR\SMFBackup.ico" 0

SectionEnd


; Uninstaller

Section "Uninstall"
  
  MessageBox MB_YESNO|MB_ICONEXCLAMATION "IF YOU HAVE BACKUPS in the installation directory, they will be REMOVED.$\nAre you sure you want to continue ?" IDNO no_remove
  
  ; Remove registry keys
  DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JavaSMFBackup"

  ; Remove files and uninstaller
  Delete "$INSTDIR\uninstall.exe"
  Delete "$DESKTOP\Java SMF Backup.lnk"

  RMDir /r "$INSTDIR"
  RMDir /r "$SMPROGRAMS\Java SMF Backup"
  
no_remove:

SectionEnd

